/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.icatportal.client.mvc;

import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.mvc.Dispatcher;

import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import org.icatportal.client.AppEvents;

/**
 *
 * @author ll56
 */
public class SearchFolderView extends View {

    private ContentPanel myDataPanel;

    public SearchFolderView(Controller controller) {
        super(controller);
    }

    @Override
    protected void handleEvent(AppEvent event) {
        switch (event.type) {
            case AppEvents.Init:
                initUI();
                break;
        }
    }

    @Override
    protected void initialize() {
    }

    protected void initUI() {

        
        myDataPanel = new ContentPanel();
        myDataPanel.setHeading("Search!");

        myDataPanel.addListener(Events.Expand, new Listener<ComponentEvent>() {

            public void handleEvent(ComponentEvent be) {
                Dispatcher.get().dispatch(AppEvents.MyData);
            }
        });


  
        SelectionListener listener = new SelectionListener<ComponentEvent>() {

            public void componentSelected(ComponentEvent ce) {
                Button btn = (Button) ce.component;
                Info.display("Click Event", "The '{0}' button was clicked.", btn.getText());
            }
        };
        VerticalPanel v = new VerticalPanel();
        v.setLayout(new RowLayout());
        v.setHorizontalAlign(Style.HorizontalAlignment.CENTER);
        v.setVerticalAlign(Style.VerticalAlignment.MIDDLE);
        v.setSpacing(5);

        Button basic = new Button("Basic", listener);
        basic.setMinWidth(120); 
        //editBt.disable();
        v.add(basic);


        Button advanced = new Button("Advanced", listener);
        advanced.setMinWidth(120); 
        //editPermission.disable();
        v.add(advanced);
        
        Button peronalized = new Button("Personal", listener);
        peronalized.setMinWidth(120); 
        peronalized.disable();
        v.add(peronalized);       
        
        Button isisSearch = new Button("ISIS", listener);
        isisSearch.setMinWidth(120); 
        isisSearch.disable();
        v.add(isisSearch);             
        
        Button dlsSearch = new Button("DLS", listener);
        dlsSearch.setMinWidth(120); 
        dlsSearch.disable();
        dlsSearch.hide();
        v.add(dlsSearch);  
        
        myDataPanel.add(v);

        ContentPanel west = (ContentPanel) Registry.get("west");
        west.setLayout(new AccordionLayout());
        west.add(myDataPanel);
    }
}
